package com.lxl.mybatis1.book.service;

import com.lxl.mybatis1.book.mapper.BookMapper;
import com.lxl.mybatis1.book.pojo.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class BookServiceImpl {
    @Autowired
    private BookMapper bookMapper;

    public List<Book> findAllBooks(){
        return bookMapper.findAllBooks();
    }

    public Book finBookById(int id){
        return bookMapper.findBookById(id);
    }

    @Transactional
    public void addBook(Book book){
        bookMapper.addBook(book);
    }

    @Transactional
    public void updateBook(Book book){
        bookMapper.updateBook(book);
    }

    @Transactional
    public void deleteBook(int id){
        bookMapper.deleteBook(id);
    }

}
